package fr.cephb.locustree.svg;

import java.awt.Rectangle;

import fr.cephb.locustree.MappedObject;

public class DefaultMappedXY
	implements MappedXY
	{
	private MappedObject o=null;
	private Rectangle bounds=new Rectangle();
	private byte side;
	
	public DefaultMappedXY()
		{
		
		}
	
	@Override
	public MappedObject getObject()
		{
		return o;
		}
	
	@Override
	public void setObject(MappedObject o)
		{
		this.o = o;
		}
	
	@Override
	public int hashCode()
		{
		return getObject().hashCode();
		}
	@Override
	public boolean equals(Object obj)
		{
		if (this == obj) return true;
		if (obj == null) return false;
		if(!(obj instanceof MappedXY)) return false;
		MappedXY other = (MappedXY) obj;
		return getObject().equals(other.getObject());
		}
	
	@Override
	public String toJSON()
		{
		return getObject().toJSON();
		}
	@Override
	public String toString()
		{
		return toJSON();
		}
	

	@Override
	public Rectangle getBounds()
		{
		return bounds;
		}
	
	public void setLabelFlag(int i)
		{
		this.side=(byte)i;
		}
	
	public int getLabelFlag()
		{
		return this.side;
		}
	
	
	int left()
		{
		return this.bounds.x;
		}
	
	int right()
		{
		return left()+this.bounds.width;
		}
	
	}
